package com.k2.exstrasensorytypredictor.controls;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.view.View;

public class Sprite extends View {
	private Bitmap bmp;
	private Matrix m;
	private float[] k;
	private float w,h;

	public Sprite(Context context, Bitmap bmp, float[] k) {
		super(context);
		this.bmp = bmp;
		w = (float)bmp.getWidth();
		h = (float)bmp.getHeight();
		this.k = k;
		m = new Matrix();
		m.setScale(k[0], k[1]);
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		canvas.drawBitmap(bmp, m, null);
	}
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		setMeasuredDimension((int)getSpriteWidth(), (int)getSpriteHeight());
	}

	public float getSpriteHeight() {
		return h*k[1];
	}

	public float getSpriteWidth() {
		return w*k[0];
	}
}
